//
//  CWQ_wrongTopicCell.m
//  BaxTer
//
//  Created by 陈武琦 on 16/9/8.
//  Copyright © 2016年 陈武琦. All rights reserved.
//

#import "CWQ_MyCollectionCell.h"
#import "NSString+Utilities.h"
@implementation CWQ_MyCollectionCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setModel:(CWQ_wrongTopicM *)model {

    _model = model;
    self.title.text = model.title;
    [self setupDate:model.date];
    [self setupFullScore:model.fullScore];
    [self setupQualify:model.qualified];
    [self setupScore:model.score];
}

- (void)setupDate:(NSString *)date {
    NSString *text = @"参考时间:";
    if (![date isEmpty]) {
       text = [text stringByAppendingFormat:@"%@",date];
    }
    NSMutableAttributedString *muAttStr = [[NSMutableAttributedString alloc] initWithString:text];
    [muAttStr setAttributes:@{NSForegroundColorAttributeName:[UIColor lightGrayColor]} range:NSMakeRange(0, muAttStr.length)];
    self.date.attributedText = muAttStr;
}

- (void)setupFullScore:(NSString *)score {
    NSString *mustr = @"满分:";
    NSString *text;
    if (![score isEmpty]) {
       text = [mustr stringByAppendingFormat:@"%@分",score];
    }
    self.fullScore.text = text;
    
}

- (void)setupQualify:(NSString *)score {
    NSString *mustr = @"合格分:";
    NSString *text;
    if (![score isEmpty]) {
       text = [mustr stringByAppendingFormat:@"%@分",score];
    }
    self.qualfied.text = text;
    
}


- (void)setupScore:(NSString *)score {
    NSString *text = @"得分:";
    if (score) {
       text = [text stringByAppendingFormat:@"%@分",score];
        if (![self.model.isQualyfied boolValue]) {
            text = [text stringByAppendingString:@"(未通过)"];
        }
        
    }
    
    NSMutableAttributedString *muAttStr = [[NSMutableAttributedString alloc] initWithString:text];
    [muAttStr setAttributes:@{NSForegroundColorAttributeName:[UIColor redColor]} range:[text rangeOfString:@"未通过"]];
    
    self.score.attributedText = muAttStr;
}



@end
